<?php

function get_url($field,$type = 1){
    if(C("is_html")!=1){
        return __CONTROL__.'&m=arc&aid='.$field['aid'];
    }
    $date = getdate();
    $search = array(
        '{htmlpath}',
        '{catdir}',
        '{aid}',
        '{y}',
        '{m}',
        '{d}'
    );
    $replace = array(
        'html',
        $field['catdir'],
        $field['aid'],
        $date['year'],
        $date['mon'],
        $date['mday']
    );
    $path = str_replace($search, $replace, $field['archtml']);
    return $type === 1 ? __ROOT__ . '/' . $path : PATH_ROOT . '/' . $path;
}

//获得栏目静态URL
function get_cat_url($cat, $type = 1) {
    //{htmlpath}/{catdir}/{cid}.html
    $search = array(
        '{htmlpath}',
        '{catdir}',
        '{cid}'
    );
    $replace = array(
        'html',
        $cat['catdir'],
        $cat['cid']
    );
    $path = str_replace($search, $replace, $cat['cathtml']);
    return $type === 1 ? __ROOT__ . '/' . $path : PATH_ROOT . '/' . $path;
}
?>
